package com.seabook.happy.website.pojos;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.google.appengine.api.datastore.Category;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Text;

public class BlogArticle {
	public static final String TITLE = "title";
	public static final String CREATE_DATE = "cDate";
	public static final String MODIFIED_DATE = "mDate";
	public static final String CONTENT = "content";
	public static final String CATEGORY = "category";
	public static final String THUMBS_UP = "tUp";
	public static final String THUMBS_DOWN = "tDown";
	public static final String COMMENTS = "comments";
	
	
	private Key key;
	private String title;
	private Date createdDate;
	private Date modifiedDate;
	private Text content;
	private Category category;
	private long thumbsUp = 0;
	private long thumbsDown = 0;
	private List<BlogComment> comments = new ArrayList<BlogComment>();
	
	public BlogArticle() {
		
	}

	public Key getKey() {
		return key;
	}

	public void setKey(Key key) {
		this.key = key;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Date getModifiedDate() {
		return modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		this.modifiedDate = modifiedDate;
	}

	public Text getContent() {
		return content;
	}

	public void setContent(Text content) {
		this.content = content;
	}
	
	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}
	
	public long getThumbsUp() {
		return thumbsUp;
	}

	public void setThumbsUp(long thumbsUp) {
		this.thumbsUp = thumbsUp;
	}

	public long getThumbsDown() {
		return thumbsDown;
	}

	public void setThumbsDown(long thumbsDown) {
		this.thumbsDown = thumbsDown;
	}

	public List<BlogComment> getComments() {
		return comments;
	}

	public void setComments(List<BlogComment> comments) {
		this.comments = comments;
	}
	
	@Override
	public String toString() {
		String toString =  title + ", " + content.getValue();
		if (comments == null || comments.size() == 0) {
			return toString;
		}
		for (BlogComment comment : comments) {
			if (comment != null)
				toString += comment.toString();
		}
		
		return toString;
	}
}
